/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.springapp.service.impl;

import com.springapp.model.Animal;
import com.springapp.repository.AnimalRepository;
import com.springapp.service.AnimalService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author Лерок
 */
@Service
public class AnimalServiceImpl implements AnimalService {
    
    @Autowired
    private AnimalRepository ar;
    
    @Override
    public List<Animal> getAll() {
        return (ArrayList<Animal>) ar.findAll();
    }
    
    public void save(Animal animal) {
        ar.save(animal);
    }
    
    public Animal getById(int id) {
        return ar.findOne(id);
    }
    
    public void delete(int id) {
        ar.delete(id);
    }
}
